<?php

namespace App\Http\Controllers;

use App\Models\Article;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    // 后台首页显示
    public function index() {
        // 读取菜单
        //$menus = Cache::get('admin_menus_' . auth()->user()->id);
        //if (empty($menus)) {
        //    $menus = (new Permission())->menuData();
        //    Cache::put('admin_menus_' . auth()->user()->id, $menus);
        //}
        $menus = [];
        $unreadMessage = '';

        // 指定模板 视图
        return view('dashboard', compact('menus','unreadMessage'));
    }

    // 控制台
    public function console() {
        $v = "version()";
        $version =  [
            'laravel' => app()::VERSION,
            'php'     => PHP_VERSION,
            'mysql'   => DB::select("select version()")[0]->$v,
            'os'      => PHP_OS
        ];
        return view('home/console', compact('version'));
    }

    // 主页一
    public function index1() {
        return view('home.index1');
    }

    // 主页二
    public function index2() {
        return view('home.index2');
    }
}
